package com.example.admin_beautiful.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.annotation.Resource;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    @ApiModelProperty("返回码")
    private Integer code;

    @ApiModelProperty("返回消息")
    private String message;

    @ApiModelProperty("返回数据")
    private T data;

    public static <T> Result<T> success(){
        return new Result<>(200,"success",null);
    }
    public static <T> Result<T> success(boolean bool){
        return (Result<T>) new Result<>(200,"success",bool);
    }
    public static <T> Result<T> success(T data) {
        return new Result<>(200, "success", data);
    }

    public static <T> Result<T> success(String message,T data){
        return new Result<>(200,message,data);
    }
//    失败
    public static <T> Result<T> fail(){
        return new Result<>(0,"fail",null);
    }

    public static <T> Result<T> fail(T data){
        return new Result<>(0,"fail",data);
    }

    public static <T> Result<T> fail(String message){
        return new Result<>(0,message,null);
    }

    public static <T> Result<T> fail(T data,String message){
        return new Result<>(0,message,data);
    }

    public static <T> Result<T> fail(Integer code,String message){
        return new Result<>(code,message,null);
    }
}
